package top.lishuoboy.javaweb.a16json_ajax;

import cn.hutool.core.collection.ListUtil;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author lishuoboy
 * @date 2022-01-14 11:23
 */
@WebServlet(name = "CheckLoginUserServlet", value = "/CheckLoginUserServlet")
public class CheckLoginUserServlet extends HttpServlet {
    private static final List<String> userList = ListUtil.list(false, "zhangsan", "lisi", "wangwu");

    /** 登录时，检查用户是否存在 */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String name = req.getParameter("name");
        if (!userList.contains(name)) {
            resp.getWriter().write("用户不存在");
        }
    }
}